package com.isdepci.project.carbon.controller;

import com.isdepci.common.utils.poi.ExcelUtil;
import com.isdepci.framework.aspectj.lang.annotation.Log;
import com.isdepci.framework.aspectj.lang.enums.BusinessType;
import com.isdepci.framework.web.controller.BaseController;
import com.isdepci.framework.web.domain.AjaxResult;
import com.isdepci.framework.web.page.TableDataInfo;
import com.isdepci.project.carbon.domain.BGreenCarbonSinkParameter;
import com.isdepci.project.carbon.service.IBGreenCarbonSinkParameterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 绿化碳汇对应二氧化碳吸收因子参数Controller
 *
 * @author isdepci
 * @date 2025-03-29
 */
@RestController
@RequestMapping("/greenCarbon/parameter")
public class BGreenCarbonSinkParameterController extends BaseController
{
    @Autowired
    private IBGreenCarbonSinkParameterService bGreenCarbonSinkParameterService;

    /**
     * 查询绿化碳汇对应二氧化碳吸收因子参数列表
     */
    //   @PreAuthorize("@ss.hasPermi('greenCarbon:parameter:list')")
    @GetMapping("/list")
    public TableDataInfo list(BGreenCarbonSinkParameter bGreenCarbonSinkParameter)
    {
        startPage();
        List<BGreenCarbonSinkParameter> list = bGreenCarbonSinkParameterService.selectBGreenCarbonSinkParameterList(bGreenCarbonSinkParameter);
        return getDataTable(list);
    }

    /**
     * 导出绿化碳汇对应二氧化碳吸收因子参数列表
     */
    //   @PreAuthorize("@ss.hasPermi('greenCarbon:parameter:export')")
    @Log(title = "绿化碳汇对应二氧化碳吸收因子参数", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BGreenCarbonSinkParameter bGreenCarbonSinkParameter)
    {
        List<BGreenCarbonSinkParameter> list = bGreenCarbonSinkParameterService.selectBGreenCarbonSinkParameterList(bGreenCarbonSinkParameter);
        ExcelUtil<BGreenCarbonSinkParameter> util = new ExcelUtil<BGreenCarbonSinkParameter>(BGreenCarbonSinkParameter.class);
        return util.exportExcel(list, "parameter");
    }

    /**
     * 获取绿化碳汇对应二氧化碳吸收因子参数详细信息
     */
    //   @PreAuthorize("@ss.hasPermi('greenCarbon:parameter:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(bGreenCarbonSinkParameterService.selectBGreenCarbonSinkParameterById(id));
    }

    /**
     * 新增绿化碳汇对应二氧化碳吸收因子参数
     */
    //   @PreAuthorize("@ss.hasPermi('greenCarbon:parameter:add')")
    @Log(title = "绿化碳汇对应二氧化碳吸收因子参数", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BGreenCarbonSinkParameter bGreenCarbonSinkParameter)
    {
        return toAjax(bGreenCarbonSinkParameterService.insertBGreenCarbonSinkParameter(bGreenCarbonSinkParameter));
    }

    /**
     * 修改绿化碳汇对应二氧化碳吸收因子参数
     */
    //   @PreAuthorize("@ss.hasPermi('greenCarbon:parameter:edit')")
    @Log(title = "绿化碳汇对应二氧化碳吸收因子参数", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BGreenCarbonSinkParameter bGreenCarbonSinkParameter)
    {
        return toAjax(bGreenCarbonSinkParameterService.updateBGreenCarbonSinkParameter(bGreenCarbonSinkParameter));
    }

    /**
     * 删除绿化碳汇对应二氧化碳吸收因子参数
     */
    //   @PreAuthorize("@ss.hasPermi('greenCarbon:parameter:remove')")
    @Log(title = "绿化碳汇对应二氧化碳吸收因子参数", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bGreenCarbonSinkParameterService.deleteBGreenCarbonSinkParameterByIds(ids));
    }
}
